<script>
	import store from "@/store";
	import {
		host
	} from '@/config/config.js'
	// 潮玩星球
	import Vue from 'vue';
	export default {
		onLaunch: function () {
			// #ifdef APP-PLUS
			this.getAppInfo()
			// #endif
			console.log('App Launch');
			uni.setNavigationBarTitle({
						 title:"魔幻世界",
						 complete(e){
							 console.log('设置标题',e);
						 }
				});

			uni.getSystemInfo({
				success: e => {
					// 状态栏高度px
					Vue.prototype.statusHeight = e.statusBarHeight;
					Vue.prototype.screenHeight = e.screenHeight;
					Vue.prototype.screenWidth = e.screenWidth;
					Vue.prototype.platform = e.platform;
					Vue.prototype.widthRatio = e.screenWidth / 375;
				}
			});
			// #ifdef MP
			uni.setEnableDebug({
				enableDebug: true
			});
			// #endif
		},
		onShow: function () {
			console.log('App Show');
		},
		onHide: function () {
			console.log('App Hide');
		},
		methods:{
			// #ifdef APP-PLUS
			async getAppInfo() {
				uni.request({
					url:host+'/api/v1/version',
					complete(data) {
						console.log(data.data,'datadata');
						if (data.data.code == 200) {
							let {
								code,
								desc,
								download,
								is_forced_update
							} = data.data.data
							console.log('App.vue');
							store.commit('NEXT_V',code)
							plus.runtime.getProperty(plus.runtime.appid, function(inf) {
								
								console.log('检查版本');
								var prevVersion = inf.version.replace(/\./g, '')
								var nextVersion = code.replace(/\./g, '')
								console.log(prevVersion, nextVersion);
								if (Number(prevVersion) < Number(nextVersion)) {
									uni.setStorageSync('newV',1)
									console.log(Number(prevVersion),Number(nextVersion),'版本');
								}
							})
							console.log(store.state.user.newVersion);
						} else {
							uni.showToast({
								icon:'none',
								title: '获取更新失败'
							})
						}
					}
				})
				
			},
			// #endif
		}
	};
</script>

<style lang="scss">
	// 全局CSS样式在这里引入
	@import '@/static/fonts/web/font.css';
	@import "@/uni_modules/uview-ui/index.scss";
	
</style>
